/*
 * $Id$
 *
 * Copyright ( c ) 2014 XuNuo Corporation. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of XuNuo
 * Corporation ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with XuNuo Corporation or a XuNuo
 * authorized reseller (the "License Agreement"). XuNuo may make changes to the
 * Confidential Information from time to time. Such Confidential Information may
 * contain errors.
 *
 * EXCEPT AS EXPLICITLY SET FORTH IN THE LICENSE AGREEMENT, XuNuo DISCLAIMS ALL
 * WARRANTIES, COVENANTS, REPRESENTATIONS, INDEMNITIES, AND GUARANTEES WITH
 * RESPECT TO SOFTWARE AND DOCUMENTATION, WHETHER EXPRESS OR IMPLIED, WRITTEN OR
 * ORAL, STATUTORY OR OTHERWISE INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A
 * PARTICULAR PURPOSE. XuNuo DOES NOT WARRANT THAT END USER'S USE OF THE
 * SOFTWARE WILL BE UNINTERRUPTED, ERROR FREE OR SECURE.
 *
 * XuNuo SHALL NOT BE LIABLE TO END USER, OR ANY OTHER PERSON, CORPORATION OR
 * ENTITY FOR INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL
 * DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR USE, WHETHER IN AN
 * ACTION IN CONTRACT, TORT OR OTHERWISE, EVEN IF XuNuo HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES. XuNuo' TOTAL LIABILITY TO END USER SHALL NOT
 * EXCEED THE AMOUNTS PAID FOR THE XuNuo SOFTWARE BY END USER DURING THE PRIOR
 * TWELVE (12) MONTHS FROM THE DATE IN WHICH THE CLAIM AROSE.  BECAUSE SOME
 * STATES OR JURISDICTIONS DO NOT ALLOW LIMITATION OR EXCLUSION OF CONSEQUENTIAL
 * OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO END USER.
 *
 * Copyright version 2.0
 */
package com.th.supcom.pds.recipefee.client.widget;

import java.util.Date;

import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.th.supcom.pds.common.client.model.CodeConstants;
import com.th.supcom.pds.common.utils.DateTimeUtils;
import com.th.supcom.pds.recipefee.client.widget.DispensaryDayConfig.ExecuteDate;

/**
 * @author 杨冲
 */
public class RecipeFeeFields
{

    /** 提交路径. */
    public static final String SCC_BRANCH = "$URL$";
    /** 提交日期. */
    public static final String SCC_LAST_MODIFICATION_DATE = "$Date$";
    /** 最终修改人员. */
    public static final String SCC_LAST_MODIFIER_NAME = "$Author$";
    /** 最终版本号. */
    public static final String SCC_REVISION = "$Revision$";
    /** 余额 */
    private TextField <String> m_balanceField;
    /** 出生年月 */
    private TextField <String> m_birthDayField;
    /** 结束时间 */
    private DateField m_endField;
    /** 姓名 */
    private TextField <String> m_nameField;

    /** 患者ID */
    private TextField <String> m_patientIdField;

    /** 处方号 */
    private TextField <String> m_recipeNoField;

    /** 性别 */
    private TextField <String> m_sexField;
    /** 处方来源 */
    private TextField <String> m_prescSource;
    /** 费别 */
    private TextField <String> m_visitTypeNameField;
    /** 就诊次数 */
    private TextField <String> m_visitIdField;
    /** 入科时间 */
    private TextField <String> m_visitBeginDateField;
    /** 在院科室 */
    private TextField <String> m_deptNameField;
    /** 在科天数 */
    private TextField <String> m_day;
    /** 床号 */
    private TextField <String> m_number;

    /** 开始时间 */
    private DateField m_startField;

    public RecipeFeeFields ()
    {
        createFields ();
    }

    /**
     * 创建组件
     */
    private void createFields ()
    {
        m_recipeNoField = new TextField <String> ();
        m_recipeNoField.setFieldLabel ("处方号");
        m_recipeNoField.setWidth (80);

        m_startField = new DateField ();
        m_startField.setFieldLabel ("时间");
        setDefaultTime ();

        m_startField.setEditable (false);
        m_startField.getPropertyEditor ()
                    .setFormat (DateTimeFormat.getFormat (CodeConstants.DATE_FORMAT_YYYY_MM_DD));
      
        m_endField = new DateField ();
        m_endField.setFieldLabel ("到");
        m_endField.setValue (new Date());
        m_endField.getPropertyEditor ()
                  .setFormat (DateTimeFormat.getFormat (CodeConstants.DATE_FORMAT_YYYY_MM_DD));

        m_prescSource = new TextField <String> ();
        m_prescSource.setFieldLabel ("患者类型");
        m_prescSource.setEnabled (false);

        m_nameField = new TextField <String> ();
        m_nameField.setFieldLabel ("姓名");
        m_nameField.setEnabled (false);

        m_patientIdField = new TextField <String> ();
        m_patientIdField.setFieldLabel ("患者ID");
        m_patientIdField.setEnabled (false);

        m_sexField = new TextField <String> ();
        m_sexField.setFieldLabel ("性别");
        m_sexField.setEnabled (false);

        m_birthDayField = new TextField <String> ();
        m_birthDayField.setFieldLabel ("年龄");
        m_birthDayField.setEnabled (false);

        m_balanceField = new TextField <String> ();
        m_balanceField.setFieldLabel ("余额");
        m_balanceField.setEnabled (false);

        m_visitTypeNameField = new TextField <String> ();
        m_visitTypeNameField.setFieldLabel ("费别");
        m_visitTypeNameField.setEnabled (false);

        m_visitIdField = new TextField <String> ();
        m_visitIdField.setFieldLabel ("就诊次数");
        m_visitIdField.setEnabled (false);

        m_visitBeginDateField = new TextField <String> ();
        m_visitBeginDateField.setFieldLabel ("入科时间");
        m_visitBeginDateField.setEnabled (false);

        m_deptNameField = new TextField <String> ();
        m_deptNameField.setFieldLabel ("在院科室");
        m_deptNameField.setEnabled (false);

        m_day = new TextField <String> ();
        m_day.setFieldLabel ("在科天数");
        m_day.setEnabled (false);

        m_number = new TextField <String> ();
        m_number.setFieldLabel ("床号");
        m_number.setEnabled (false);

    }

    private void setDefaultTime ()
    {
        DispensaryDayConfig.getLimitedDay (new ExecuteDate ()
        {

            @Override
            public void getDateOrDay (Integer day)
            {
                m_startField.setValue (DateTimeUtils.getDateAddDay (new Date (), -day));

            }
        });
    }

    /**
     * 获取余额组件
     * 
     * @return the balanceField
     */
    public TextField <String> getBalanceField ()
    {

        return m_balanceField;
    }

    /**
     * 获取出生年月组件
     * 
     * @return the birthDayField
     */
    public TextField <String> getBirthDayField ()
    {

        return m_birthDayField;
    }

    /**
     * 获取结束日期组件
     * 
     * @return the endField
     */
    public DateField getEndField ()
    {

        return m_endField;
    }

    /**
     * 获取姓名组件
     * 
     * @return the nameField
     */
    public TextField <String> getNameField ()
    {

        return m_nameField;
    }

    /**
     * 获取患者ID组件
     * 
     * @return the patientIdField
     */
    public TextField <String> getPatientIdField ()
    {

        return m_patientIdField;
    }

    /**
     * 返回刷卡组件
     * 
     * @return the recipeNoField
     */
    public TextField <String> getRecipeNoField ()
    {

        return m_recipeNoField;
    }

    /**
     * 获取性别组件
     * 
     * @return the sexField
     */
    public TextField <String> getSexField ()
    {

        return m_sexField;
    }

    /**
     * 返回开始日期组件
     * 
     * @return the startField
     */
    public DateField getStartField ()
    {

        return m_startField;
    }

    public TextField <String> getPrescSource ()
    {

        return m_prescSource;
    }

    public TextField <String> getVisitTypeNameField ()
    {

        return m_visitTypeNameField;
    }

    public TextField <String> getVisitIdField ()
    {

        return m_visitIdField;
    }

    public TextField <String> getVisitBeginDateField ()
    {

        return m_visitBeginDateField;
    }

    public TextField <String> getDeptNameField ()
    {

        return m_deptNameField;
    }

    public TextField <String> getDay ()
    {

        return m_day;
    }

    public TextField <String> getNumber ()
    {

        return m_number;
    }

}
